import { createRouter, createWebHistory } from 'vue-router'
// const files = import.meta.glob('./hooks/*.js', { eager: true }) 
import checkUserLogin from './hooks/checkUserLogin'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/home/index.vue'),
      redirect: '/admin',
      children: [
        {
          path: '/admin',
          component: () => import('@/views/admin/index.vue'),
        },
        {
          path: '/singin',
          component: () => import('@/views/singin/index.vue'),
        },
        {
          path: '/application',
          component: () => import('@/views/application/index.vue'),

        },
        {
          path:'guest',
          component: () => import('@/views/guest/index.vue'),

        },
        {
          path:'schoolMessage',
          component: () => import('@/views/list/index.vue'),
          meta:{
            title1:"新增通知",
            title2:'新增动态'
          }
        },
        {
          path:'schoolNotice',
          component: () => import('@/views/list/index.vue'),

        },

        {
          path:"/cardManage",
          component:()=>import('@/views/cardManage/index.vue')
        },
        {
          path:'addText',
          component: () => import('@/views/addText/index.vue'),

        },
        {
          path:'addNotice',
          component: () => import('@/views/addNotice/index.vue'),

        },

        {
          path:'classTrends',
          component: () => import('@/views/list/index.vue'),

        },
        {
          path:'classNotice',
          component: () => import('@/views/list/index.vue'),

        },
        {
          path: '/message',
          component: () => import('@/views/message/index.vue'),
        },
        {
          path: '/kecheng',
          component: () => import('@/views/kecheng/index.vue'),
        },
        {
          path: '/causeeend',
          component: () => import('@/views/causeeend/index.vue'),
        },
        {
          path: '/my',
          component: () => import('@/views/my/index.vue'),
        },
        {
          path: "/personMassage",
          component: () => import("@/views/myPageList/index.vue"),
        },
        {
          path: "/changePassword",
          component: () => import("@/views/myPageList/password.vue"),
        },
        {
          path: "/pswd",
          component: () => import("@/views/myPageList/pswd.vue"),
        },

      ]
    },
    {
      path:'/login',
      component: () => import('@/views/login/index.vue'),
      meta: {
        nologin: true
      }
    },
  ]
})

  // router.beforeEach((files[key]).default)
  router.beforeEach(checkUserLogin)

export default router
